package icu.wdtt.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Configuration
@EnableSwagger2WebMvc
public class Swagger2Config {
    /**
     * 注入一个Docket
     * @return
     */
    @Bean
    public Docket docket(){
        //一般固定写法
        /*
            DocumentationType.SWAGGER_2:调用版本，现在一般为2
         */
         return new Docket(DocumentationType.SWAGGER_2)
                 .apiInfo(apiInfo())
                 .select()
                 //扫描Controller所在的包
                 //调用basePackage方法来扫描包
                 .apis(RequestHandlerSelectors.basePackage("icu.wdtt.controller"))
                 .build()
                 //忽略某些参数
                 .ignoredParameterTypes(HttpSession.class, HttpServletRequest.class, HttpServletResponse.class);
    }

    public ApiInfo apiInfo(){
       return new ApiInfoBuilder()
               .title("哈哈网盘接口文档")
               .description("swagger-bootstrap-ui")
               .contact("boasad@163.com")
               .version("1.0")
               .build();
    }
}
